import java.util.Arrays;

public class Test {
        public static void rotate(int[] nums, int k) {
            k %= nums.length;
            int[] array = new int[nums.length*2];
            for(int i = 0;i<nums.length;i++){
                array[i+k] = nums[i];
            }
            for(int i = 0;i<k;i++){
                array[i] = array[nums.length+i];
            }
            for(int i = 0;i<nums.length;i++){
                nums[i] = array[i];
            }
            System.out.println(Arrays.toString(nums));


        }

    public static void rotate1(int[] nums, int k) {

        int length = nums.length;
        int from = length - k;
        int[] array = Arrays.copyOfRange(nums,from,length);
        System.arraycopy(nums,0,nums,k,nums.length-k);
        System.arraycopy(array,0,nums,0,array.length);

    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5,6,7};
        rotate(nums,3);
    }

    public static int[][] get2Array(int n){
        int[][] array = new int[n][];
        for(int i = 0; i < n; i++) {
            array[i] = new int[n-i];
        }

        return array;
    }

    public static void main3(String[] args) {
        System.out.println(Arrays.deepToString(get2Array(4)));
    }
    public static int missingNumber(int[] nums) {
        int n = nums.length;
        boolean[] array = new boolean[n+1];
        for (int i = 0; i < n; i++){
            int index = nums[i];
            array[index] = true;
        }
        for (int j = 0; j < array.length; j++){
            if(array[j] == false){
                return j;
            }
        }
        return 0;
    }

    public static void main1(String[] args) {
        int[] array = {1,0,3};
        System.out.println(missingNumber(array));
    }
    long factorial(int N) {
        return N < 2 ? N : factorial(N-1) * N;
    }

    int fibonacci(int N) {
        return N < 2 ? N : fibonacci(N-1)+fibonacci(N-2);
    }

    long[] fibonacci1(int n) {
        long[] fibArray = new long[n + 1];
        fibArray[0] = 0;
        fibArray[1] = 1;
        for (int i = 2; i <= n ; i++) {
            fibArray[i] = fibArray[i - 1] + fibArray [i - 2];
        }
        return fibArray;
    }

    void Swap(int[] array,int i,int j){

    }

    void bubbleSort(int[] array) {
        for (int end = array.length; end > 0; end--) {
            boolean sorted = true;
            for (int i = 1; i < end; i++) {
                if (array[i - 1] > array[i]) {
                    Swap(array, i - 1, i);
                    sorted = false;
                }
            }
            if (sorted == true) {
                break;
            }
        }
    }
}

